package com.txts.road.app.device.controller;

import com.txts.road.app.device.model.vo.DeviceConfigVO;
import com.txts.road.app.device.service.DeviceConfigService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.txts.road.app.device.model.dto.DeviceConfigDTO;

import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 设备配置前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 10:47
 */
@Tag(name = "设备配置接口")
@RestController
@RequestMapping("/api/v1/device-config")
@RequiredArgsConstructor
public class DeviceConfigController {
    private final DeviceConfigService deviceConfigService;


    /**
     * 获取设备配置
     */
    @Operation(summary = "获取设备配置")
    @GetMapping("/{deviceId}/config")
    public ResponseDTO<List<DeviceConfigVO>> getDeviceConfig(@PathVariable Long deviceId) {
        return ResponseDTO.ok(deviceConfigService.getDeviceConfig(deviceId));
    }

    /**
     * 更新设备配置
     */
    @Operation(summary = "更新设备配置")
    @PutMapping("/update/config")
    public ResponseDTO<Boolean> updateDeviceConfig(@Valid @RequestBody DeviceConfigDTO configDTO) {
        return ResponseDTO.ok(deviceConfigService.updateDeviceConfig( configDTO));
    }

//    /**
//     * 固件升级
//     */
//    @Operation(summary = "固件升级")
//    @PostMapping("/{deviceId}/firmware/upgrade")
//    public ResponseDTO<> upgradeFirmware(@PathVariable Long deviceId, @Valid @RequestBody FirmwareUpgradeDTO upgradeDTO) {
//        return ResponseDTO.ok(deviceConfigService.upgradeFirmware(deviceId, upgradeDTO));
//
//    }
//
//    /**
//     * 获取固件升级进度
//     */
//    @Operation(summary = "获取固件升级进度")
//    @GetMapping("/{deviceId}/firmware/progress")
//    public ResponseDTO<> getUpgradeProgress(@PathVariable Long deviceId) {
//        return ResponseDTO.ok(deviceConfigService.getUpgradeProgress(deviceId));
//    }

}
